<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>SWM34S_LVGL7.11_SWMUI: C:/Users/DELL/Desktop/Commit/lvgl/SWM34S_LVGL7.11_SWMUI_20230515/APP/Common Module/mem_sdram.c 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">SWM34S_LVGL7.11_SWMUI<span id="projectnumber">&#160;V7.9</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.5 -->
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_0ca16891106f5a3e9ad635a0d6c5f98f.html">APP</a></li><li class="navelem"><a class="el" href="dir_df4e0e4e72f77ab290fd1a24f190250a.html">Common Module</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">mem_sdram.c</div></div>
</div><!--header-->
<div class="contents">
<a href="mem__sdram_8c.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &lt;string.h&gt;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="preprocessor">#include &quot;<a class="code" href="mem__sdram_8h.html">mem_sdram.h</a>&quot;</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span> </div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="preprocessor">#include &quot;<a class="code" href="version_8h.html">version.h</a>&quot;</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span><span class="preprocessor">#include &quot;lv_conf.h&quot;</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span> </div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span><span class="comment">/* SDRAM 内存管理 :</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="comment"> * SDRAMM_BASE =&gt;</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span><span class="comment"> *</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span><span class="comment"> * 功能保留区 : 静态编译阶段确定, 用于实现特定功能, 如不需要某些功能可根据需要删减/复用</span></div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span><span class="comment"> * {</span></div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span><span class="comment"> *      [LCD_W * LCD_H * 2]     : LVGL 绘图区, 充当显存 (详见 lv_porting/lv_port_disp.c)</span></div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span><span class="comment"> *      [LCD_W * LCD_H]         : (512KB)  JPEG 解码缓冲区, 用于全局 JPEG 解码图片(详见 bsp/dev_jpeg.c)</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span><span class="comment"> *      [LV_MEM_SIZE]           : LVGL 控件对象所需内存 (详见 lv_conf.h line-91)</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span><span class="comment"> *      [UserBoot 2 Cache Buff] : (4KB * 2)  UserBoot 读写双缓存</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span><span class="comment"> * }</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span><span class="comment"> *</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span><span class="comment"> * [Other Memory] :  由本模块进行管理</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span><span class="comment"> *</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span><span class="comment"> * &lt;= [SDRAMM_BASE + SDRAMM_SIZE]</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span><span class="comment"> */</span></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span><span class="comment">/*******************************************************************************************************************************************</span></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span><span class="comment"> * Private Define</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span><span class="comment"> *******************************************************************************************************************************************/</span></div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#afab4ed7f0bb2a4144c712210d8c4c43e">   47</a></span><span class="preprocessor">#define ALIGN_X                 (4)</span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span> </div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#afaf774943f1ebd4ab9b70edd87be3bce">   50</a></span><span class="preprocessor">#define MEM_ALIGN_UP(size)      ALIGN_UP((size), (ALIGN_X))</span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span> </div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span><span class="comment">/*</span></div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span><span class="comment"> * 在 &quot;lv_conf.h&quot; 中 修改 #define LV_MEM_SIZE 取值可变更切换此处内存管理方式</span></div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span><span class="comment"> * 0     - LVGL 库内建的内存管理</span></div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span><span class="comment"> * 1     - 内存池 + 堆实现(优点:地址连续,不会产生内存碎片, 分配速度快;   缺点:当位于高地址的内存块被分配获取后, 不能释放低地址的内存块)</span></div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span><span class="comment"> * other - 可以自己实现一套内存管理机制, 保持接口一致即可</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span><span class="comment"> */</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span><span class="preprocessor">#if (LV_MEM_SIZE != (SDRAMM_SIZE - (LCD_HDOT * LCD_VDOT * LCD_FMT * 2) - 512 * 1024 - 4096 * 2))</span></div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span> </div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#afeab576605dd7cd387b47f9a54203abb">   61</a></span><span class="preprocessor">#define MAGIC_SWM34S        (0xABCDDCBA)</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span> </div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span><span class="comment">/*******************************************************************************************************************************************</span></div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span><span class="comment"> * Private Typedef</span></div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span><span class="comment"> *******************************************************************************************************************************************/</span></div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"><a class="line" href="structmem__header__t.html">   66</a></span><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span>{</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"><a class="line" href="structmem__header__t.html#a43dc3ebb377552917742f3765e0517d0">   68</a></span>    <span class="keywordtype">size_t</span> <a class="code hl_variable" href="structmem__header__t.html#a43dc3ebb377552917742f3765e0517d0">magic</a>; </div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"><a class="line" href="structmem__header__t.html#a854352f53b148adc24983a58a1866d66">   69</a></span>    <span class="keywordtype">size_t</span> <a class="code hl_variable" href="structmem__header__t.html#a854352f53b148adc24983a58a1866d66">size</a>;  </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"><a class="line" href="structmem__header__t.html#a735984d41155bc1032e09bece8f8d66d">   70</a></span>    <span class="keywordtype">void</span> *<a class="code hl_variable" href="structmem__header__t.html#a735984d41155bc1032e09bece8f8d66d">data</a>;   </div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>} <a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a>;   </div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"><a class="line" href="structmm__t.html">   73</a></span><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>{</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"><a class="line" href="structmm__t.html#af042d159841ddd8f248d6d49bbcbc38c">   75</a></span>    <span class="keyword">const</span> <span class="keywordtype">void</span> *<a class="code hl_variable" href="structmm__t.html#af042d159841ddd8f248d6d49bbcbc38c">addr</a>;  </div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"><a class="line" href="structmm__t.html#a685609860d73ccd0d45ada287ab9ab5f">   76</a></span>    <span class="keyword">const</span> <span class="keywordtype">size_t</span> <a class="code hl_variable" href="structmm__t.html#a685609860d73ccd0d45ada287ab9ab5f">size</a>; </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span><span class="comment">//    size_t block_size;        /**&lt; 内存块大小 / Bytes */</span></div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span><span class="comment">//    uint8_t *block_list;      /**&lt; 内存块列表 */</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span><span class="comment">//    size_t block_total_count; /**&lt; 内存池数据区域中能够容纳的最大内存块数 */</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span><span class="comment">//    size_t block_free_count;  /**&lt; 内存池中空闲的内存块数 */</span></div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span> </div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"><a class="line" href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">   83</a></span>    uint8_t <a class="code hl_variable" href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">thread_mutex</a>; </div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"><a class="line" href="structmm__t.html#a9f8bf599d89043703a2ccce45dfc6343">   84</a></span>    <span class="keywordtype">size_t</span> <a class="code hl_variable" href="structmm__t.html#a9f8bf599d89043703a2ccce45dfc6343">ptr</a>;           </div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span>} <a class="code hl_struct" href="structmm__t.html">mm_t</a>; </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span><span class="comment">/*******************************************************************************************************************************************</span></div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span><span class="comment"> * Private Variable</span></div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span><span class="comment"> *******************************************************************************************************************************************/</span></div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#a4e9a18ab509601b83a6841d43cc49461">   92</a></span><span class="keyword">static</span> uint8_t <a class="code hl_variable" href="mem__sdram_8c.html#a4e9a18ab509601b83a6841d43cc49461">Memory_Pool</a>[(<a class="code hl_define" href="version_8h.html#a52545d915cb8a3be458871130e58997a">SDRAMM_SIZE</a> - (<a class="code hl_define" href="version_8h.html#a23a8c652045ed1831883b0c6785bea16">LCD_HDOT</a> * <a class="code hl_define" href="version_8h.html#a13286deaebfd1c39a4e3638e8718c274">LCD_VDOT</a> * <a class="code hl_define" href="version_8h.html#ae3f7a8bd03ba0b575f7ece837aab91aa">LCD_FMT</a> * 2) - 512 * 1024 - LV_MEM_SIZE - 4096 * 2)]</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>    __attribute__((section(<span class="stringliteral">&quot;.SDRAM1&quot;</span>), aligned(4)));</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span> </div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">   96</a></span><span class="keyword">static</span> <span class="keyword">volatile</span> <a class="code hl_struct" href="structmm__t.html">mm_t</a> <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a> = {</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span>    .<a class="code hl_variable" href="structmm__t.html#af042d159841ddd8f248d6d49bbcbc38c">addr</a> = (<span class="keywordtype">void</span> *)<a class="code hl_variable" href="mem__sdram_8c.html#a4e9a18ab509601b83a6841d43cc49461">Memory_Pool</a>,</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>    .size = <span class="keyword">sizeof</span>(<a class="code hl_variable" href="mem__sdram_8c.html#a4e9a18ab509601b83a6841d43cc49461">Memory_Pool</a>) / <span class="keyword">sizeof</span>(<a class="code hl_variable" href="mem__sdram_8c.html#a4e9a18ab509601b83a6841d43cc49461">Memory_Pool</a>[0]),</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span>    .thread_mutex = 0,</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span>    .ptr = 0,</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span>};</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span> </div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span><span class="preprocessor">#ifdef HOOK_ENABLE</span></div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span><span class="keyword">typedef</span> void (*sdram_malloc_hook_t)(<span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> size);</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span><span class="keyword">typedef</span> void (*sdram_free_hook_t)(<span class="keywordtype">void</span> *ptr);</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span> </div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span><span class="keyword">static</span> sdram_malloc_hook_t sdram_malloc_hook;</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span><span class="keyword">static</span> sdram_free_hook_t sdram_free_hook;</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span> </div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span><span class="keywordtype">void</span> sdram_malloc_set_hook(sdram_malloc_hook_t hook)</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span>{</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span>    sdram_malloc_hook = hook;</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span>}</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span> </div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span><span class="keywordtype">void</span> sdram_free_set_hook(sdram_free_hook_t hook)</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>{</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>    sdram_free_hook = hook;</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span>}</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno">  119</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span> </div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span><span class="comment">/*******************************************************************************************************************************************</span></div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span><span class="comment"> * Public Variable</span></div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span><span class="comment"> *******************************************************************************************************************************************/</span></div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#ae1630464a6d7686e9e41daf4b38e74a8">  130</a></span><span class="keywordtype">void</span> *<a class="code hl_function" href="mem__sdram_8c.html#ae1630464a6d7686e9e41daf4b38e74a8">sdram_malloc</a>(<span class="keywordtype">size_t</span> size)</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span>{</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno">  132</span>    <span class="keywordtype">size_t</span> base_addr = (size_t)(<a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#af042d159841ddd8f248d6d49bbcbc38c">addr</a>);</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span>    <span class="keywordtype">size_t</span> max_size = <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a685609860d73ccd0d45ada287ab9ab5f">size</a>;</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>    <span class="keywordtype">size_t</span> ptr = <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a9f8bf599d89043703a2ccce45dfc6343">ptr</a>;</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span>    <span class="keywordtype">size_t</span> ptr_size = size;</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span>    </div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span>    <span class="keywordflow">if</span> (ptr &gt;= max_size - size || size == 0) </div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span>        <span class="keywordflow">return</span> NULL; <span class="comment">/* assert */</span></div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span>    </div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno">  140</span><span class="preprocessor">    #define TWO_ADD(x, y)       ((x) + (y))</span></div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno">  141</span> </div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno">  142</span>    <span class="comment">/* 地址对齐 */</span></div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno">  143</span>    <span class="keywordtype">size_t</span> offset_pad = <a class="code hl_define" href="mem__sdram_8c.html#afaf774943f1ebd4ab9b70edd87be3bce">MEM_ALIGN_UP</a>( <a class="code hl_define" href="mem__sdram_8c.html#a587262dc560a7754aea60ff3704839d2">TWO_ADD</a>(ptr, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a>)) ) - ptr;</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno">  144</span> </div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno">  145</span>    <span class="comment">/* 计算总占用 */</span></div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno">  146</span>    ptr_size += offset_pad;</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno">  147</span> </div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno">  148</span>    <span class="comment">/* 剩余容量判定 */</span></div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno">  149</span>    <span class="keywordflow">if</span> (ptr &gt;= max_size - ptr_size)</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span>        <span class="keywordflow">return</span> NULL;</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span> </div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span>    <span class="comment">/* 写入前加锁以保护临界段, 避免同时访问竞争产生不可预知的内存错误 */</span></div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span>    <span class="keywordflow">if</span> (<a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">thread_mutex</a> != 0)</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span>        <span class="keywordflow">return</span> NULL;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span>    <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">thread_mutex</a> = 1;</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span>    </div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span>    <span class="comment">/* 填充内存块 */</span></div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span>    <a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a> *header = (<a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a> *)(<a class="code hl_define" href="mem__sdram_8c.html#a587262dc560a7754aea60ff3704839d2">TWO_ADD</a>(base_addr, ptr + offset_pad) - <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a>));</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span>    header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a43dc3ebb377552917742f3765e0517d0">magic</a> = <a class="code hl_define" href="mem__sdram_8c.html#afeab576605dd7cd387b47f9a54203abb">MAGIC_SWM34S</a>;</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span>    header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a854352f53b148adc24983a58a1866d66">size</a> = ptr_size;</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span>    header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a735984d41155bc1032e09bece8f8d66d">data</a> = (<span class="keywordtype">void</span> *)(<a class="code hl_define" href="mem__sdram_8c.html#a587262dc560a7754aea60ff3704839d2">TWO_ADD</a>(base_addr, ptr + offset_pad));</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span>    </div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span>    <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a9f8bf599d89043703a2ccce45dfc6343">ptr</a> += ptr_size;</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno">  164</span>    </div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno">  165</span><span class="preprocessor">#ifdef HOOK_ENABLE</span></div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno">  166</span>    <span class="keywordflow">if</span> (sdram_malloc_hook)</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno">  167</span>        sdram_malloc_hook((<span class="keywordtype">void</span> *)ptr, ptr_size);</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno">  168</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno">  169</span> </div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno">  170</span>    <span class="comment">/* 释放锁 */</span></div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno">  171</span>    <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">thread_mutex</a> = 0;</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno">  172</span>    <span class="keywordflow">return</span> header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a735984d41155bc1032e09bece8f8d66d">data</a>;</div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno">  173</span>    </div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno">  174</span><span class="preprocessor">    #undef TWO_ADD</span></div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno">  175</span>}</div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno">  176</span> </div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#a9ef7e7053d4000fe99a7eacc8d9346d7">  183</a></span>uint8_t <a class="code hl_function" href="mem__sdram_8c.html#a9ef7e7053d4000fe99a7eacc8d9346d7">sdram_free</a>(<span class="keywordtype">void</span> *ptr)</div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno">  184</span>{</div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno">  185</span>    <a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a> *header = (<a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a> *)((<span class="keywordtype">size_t</span>)ptr - <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a>));</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno">  186</span> </div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno">  187</span>    <span class="keywordflow">if</span> (header == NULL \</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno">  188</span>        || ( (<span class="keywordtype">size_t</span>)header &lt;= (size_t)(<a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#af042d159841ddd8f248d6d49bbcbc38c">addr</a>) ) \</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno">  189</span>        || ( (<span class="keywordtype">size_t</span>)header &gt;= <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a685609860d73ccd0d45ada287ab9ab5f">size</a> + (size_t)(<a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#af042d159841ddd8f248d6d49bbcbc38c">addr</a>) - <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structmem__header__t.html">mem_header_t</a>) ) \</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno">  190</span>        || header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a43dc3ebb377552917742f3765e0517d0">magic</a> != <a class="code hl_define" href="mem__sdram_8c.html#afeab576605dd7cd387b47f9a54203abb">MAGIC_SWM34S</a> \</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno">  191</span>        || header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a854352f53b148adc24983a58a1866d66">size</a> &gt; <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a9f8bf599d89043703a2ccce45dfc6343">ptr</a> \</div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno">  192</span>        )</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno">  193</span>        {</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno">  194</span>            <span class="keywordflow">return</span> 1; <span class="comment">/* assert */</span></div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno">  195</span>        }</div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno">  196</span> </div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno">  197</span>    <span class="comment">/* 写入前加锁以保护临界段, 避免同时访问竞争产生不可预知的内存错误 */</span></div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno">  198</span>    <span class="keywordflow">if</span> (<a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">thread_mutex</a> != 0)</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno">  199</span>        <span class="keywordflow">return</span> 2;</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span>    <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">thread_mutex</a> = 1;</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno">  201</span> </div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno">  202</span>    <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a9f8bf599d89043703a2ccce45dfc6343">ptr</a> -= header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a854352f53b148adc24983a58a1866d66">size</a>;</div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno">  203</span>    </div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno">  204</span>    <span class="comment">/* 立即擦空(可选), 一般标记为脏值即可, 无须擦空而消耗时间 </span></div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno">  205</span><span class="comment">    size_t addr = (size_t)header;</span></div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno">  206</span><span class="comment">    size_t size = (size_t)(header-&gt;size);</span></div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno">  207</span><span class="comment">    memset((void *)addr, 0, size);</span></div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno">  208</span><span class="comment">    */</span></div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno">  209</span>    </div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno">  210</span>    <span class="comment">/* 清除内存头, 标记为脏块 */</span></div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno">  211</span>    <span class="comment">//memset(free_head, 0, sizeof(mem_header_t));</span></div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno">  212</span>    header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a43dc3ebb377552917742f3765e0517d0">magic</a> = 0;</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno">  213</span>    header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a854352f53b148adc24983a58a1866d66">size</a> = ~0;</div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno">  214</span>    header-&gt;<a class="code hl_variable" href="structmem__header__t.html#a735984d41155bc1032e09bece8f8d66d">data</a> = NULL;</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno">  215</span>    </div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno">  216</span><span class="preprocessor">#ifdef HOOK_ENABLE</span></div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno">  217</span>    <span class="keywordflow">if</span> (sdram_free_hook)</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno">  218</span>        sdram_free_hook((<span class="keywordtype">void</span> *)ptr);</div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno">  219</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno">  220</span>    </div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno">  221</span>    <span class="comment">/* 释放锁 */</span></div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno">  222</span>    <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">thread_mutex</a> = 0;</div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno">  223</span>    <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno">  224</span>}</div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno">  225</span> </div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#a5518679ba96822661667b2b3d5182379">  231</a></span><span class="keywordtype">size_t</span> <a class="code hl_function" href="mem__sdram_8c.html#a5518679ba96822661667b2b3d5182379">sdram_get_idle_size</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno">  232</span>{</div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno">  233</span>    <span class="keywordflow">return</span> (<a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a685609860d73ccd0d45ada287ab9ab5f">size</a> - <a class="code hl_variable" href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a>.<a class="code hl_variable" href="structmm__t.html#a9f8bf599d89043703a2ccce45dfc6343">ptr</a>);</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno">  234</span>}</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno">  235</span> </div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno">  236</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno">  237</span> </div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno">  238</span><span class="preprocessor">#include &quot;lvgl.h&quot;</span></div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno">  239</span> </div>
<div class="line"><a id="l00246" name="l00246"></a><span class="lineno">  246</span><span class="keywordtype">void</span> *<a class="code hl_function" href="mem__sdram_8c.html#ae1630464a6d7686e9e41daf4b38e74a8">sdram_malloc</a>(<span class="keywordtype">size_t</span> size)</div>
<div class="line"><a id="l00247" name="l00247"></a><span class="lineno">  247</span>{</div>
<div class="line"><a id="l00248" name="l00248"></a><span class="lineno">  248</span>    size = <a class="code hl_define" href="mem__sdram_8c.html#afaf774943f1ebd4ab9b70edd87be3bce">MEM_ALIGN_UP</a>(size);</div>
<div class="line"><a id="l00249" name="l00249"></a><span class="lineno">  249</span>    <span class="comment">/* lvgl 暂未提供内存对齐选项, 需要等到 V9 版本才有 */</span></div>
<div class="line"><a id="l00250" name="l00250"></a><span class="lineno">  250</span> </div>
<div class="line"><a id="l00251" name="l00251"></a><span class="lineno">  251</span><span class="preprocessor">#if 1 </span><span class="comment">// malloc</span></div>
<div class="line"><a id="l00252" name="l00252"></a><span class="lineno">  252</span>    <span class="keywordflow">return</span> lv_mem_alloc(size);</div>
<div class="line"><a id="l00253" name="l00253"></a><span class="lineno">  253</span> </div>
<div class="line"><a id="l00254" name="l00254"></a><span class="lineno">  254</span><span class="preprocessor">#else </span><span class="comment">// calloc</span></div>
<div class="line"><a id="l00255" name="l00255"></a><span class="lineno">  255</span>    <span class="keywordtype">void</span> *ptr = lv_mem_alloc(size);</div>
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno">  256</span>    memset(ptr, 0, size);</div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno">  257</span>    <span class="keywordflow">return</span> ptr;</div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno">  258</span> </div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno">  259</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno">  260</span>}</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno">  261</span> </div>
<div class="line"><a id="l00268" name="l00268"></a><span class="lineno">  268</span>uint8_t <a class="code hl_function" href="mem__sdram_8c.html#a9ef7e7053d4000fe99a7eacc8d9346d7">sdram_free</a>(<span class="keywordtype">void</span> *ptr)</div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno">  269</span>{</div>
<div class="line"><a id="l00270" name="l00270"></a><span class="lineno">  270</span>    lv_mem_free(ptr);</div>
<div class="line"><a id="l00271" name="l00271"></a><span class="lineno">  271</span>    <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00272" name="l00272"></a><span class="lineno">  272</span>}</div>
<div class="line"><a id="l00273" name="l00273"></a><span class="lineno">  273</span> </div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno">  279</span><span class="keywordtype">size_t</span> <a class="code hl_function" href="mem__sdram_8c.html#a5518679ba96822661667b2b3d5182379">sdram_get_idle_size</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno">  280</span>{</div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno">  281</span>    lv_mem_monitor_t mem_monitor;</div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno">  282</span>    lv_mem_monitor(&amp;mem_monitor);</div>
<div class="line"><a id="l00283" name="l00283"></a><span class="lineno">  283</span>    <span class="keywordflow">return</span> mem_monitor.free_size;</div>
<div class="line"><a id="l00284" name="l00284"></a><span class="lineno">  284</span>}</div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno">  285</span> </div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno">  286</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00287" name="l00287"></a><span class="lineno">  287</span> </div>
<div class="line"><a id="l00294" name="l00294"></a><span class="lineno"><a class="line" href="mem__sdram_8c.html#a1792f14452da6eb907e7a58e57c20ba6">  294</a></span>uint8_t <a class="code hl_function" href="mem__sdram_8c.html#a1792f14452da6eb907e7a58e57c20ba6">mm_test</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno">  295</span>{</div>
<div class="line"><a id="l00296" name="l00296"></a><span class="lineno">  296</span>    <span class="keywordtype">void</span> *ptr[100];</div>
<div class="line"><a id="l00297" name="l00297"></a><span class="lineno">  297</span>    <span class="keywordtype">size_t</span> free_size = 0;</div>
<div class="line"><a id="l00298" name="l00298"></a><span class="lineno">  298</span>    uint8_t res = 0;</div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno">  299</span>    <span class="keywordflow">for</span> (uint32_t i = 0; i &lt; <span class="keyword">sizeof</span>(ptr) / <span class="keyword">sizeof</span>(ptr[0]); ++i)</div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno">  300</span>    {</div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno">  301</span>        ptr[i] = <a class="code hl_function" href="mem__sdram_8c.html#ae1630464a6d7686e9e41daf4b38e74a8">sdram_malloc</a>(i * 1024);</div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno">  302</span>        free_size = <a class="code hl_function" href="mem__sdram_8c.html#a5518679ba96822661667b2b3d5182379">sdram_get_idle_size</a>();</div>
<div class="line"><a id="l00303" name="l00303"></a><span class="lineno">  303</span>        <span class="keywordflow">if</span> (ptr[i] == NULL)</div>
<div class="line"><a id="l00304" name="l00304"></a><span class="lineno">  304</span>        {</div>
<div class="line"><a id="l00305" name="l00305"></a><span class="lineno">  305</span>            res = 3;</div>
<div class="line"><a id="l00306" name="l00306"></a><span class="lineno">  306</span>            <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00307" name="l00307"></a><span class="lineno">  307</span>        }</div>
<div class="line"><a id="l00308" name="l00308"></a><span class="lineno">  308</span>        res = <a class="code hl_function" href="mem__sdram_8c.html#a9ef7e7053d4000fe99a7eacc8d9346d7">sdram_free</a>(ptr[i]);</div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno">  309</span>        free_size = <a class="code hl_function" href="mem__sdram_8c.html#a5518679ba96822661667b2b3d5182379">sdram_get_idle_size</a>();</div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno">  310</span>        <span class="keywordflow">if</span> (res != 0)</div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno">  311</span>            <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00312" name="l00312"></a><span class="lineno">  312</span>    }</div>
<div class="line"><a id="l00313" name="l00313"></a><span class="lineno">  313</span>    <span class="keywordflow">return</span> res;</div>
<div class="line"><a id="l00314" name="l00314"></a><span class="lineno">  314</span>}</div>
<div class="ttc" id="amem__sdram_8c_html_a1792f14452da6eb907e7a58e57c20ba6"><div class="ttname"><a href="mem__sdram_8c.html#a1792f14452da6eb907e7a58e57c20ba6">mm_test</a></div><div class="ttdeci">uint8_t mm_test(void)</div><div class="ttdoc">测试本模块内存管理</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00294">mem_sdram.c:294</a></div></div>
<div class="ttc" id="amem__sdram_8c_html_a427b47e51da122b06c45f634db009adf"><div class="ttname"><a href="mem__sdram_8c.html#a427b47e51da122b06c45f634db009adf">Memory_Handle</a></div><div class="ttdeci">static volatile mm_t Memory_Handle</div><div class="ttdoc">内存句柄</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00096">mem_sdram.c:96</a></div></div>
<div class="ttc" id="amem__sdram_8c_html_a4e9a18ab509601b83a6841d43cc49461"><div class="ttname"><a href="mem__sdram_8c.html#a4e9a18ab509601b83a6841d43cc49461">Memory_Pool</a></div><div class="ttdeci">static uint8_t Memory_Pool[(SDRAMM_SIZE -(LCD_HDOT *LCD_VDOT *LCD_FMT *2) - 512 *1024 - LV_MEM_SIZE - 4096 *2)]</div><div class="ttdoc">内存池</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00092">mem_sdram.c:93</a></div></div>
<div class="ttc" id="amem__sdram_8c_html_a5518679ba96822661667b2b3d5182379"><div class="ttname"><a href="mem__sdram_8c.html#a5518679ba96822661667b2b3d5182379">sdram_get_idle_size</a></div><div class="ttdeci">size_t sdram_get_idle_size(void)</div><div class="ttdoc">获取空闲可用内存大小</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00231">mem_sdram.c:231</a></div></div>
<div class="ttc" id="amem__sdram_8c_html_a587262dc560a7754aea60ff3704839d2"><div class="ttname"><a href="mem__sdram_8c.html#a587262dc560a7754aea60ff3704839d2">TWO_ADD</a></div><div class="ttdeci">#define TWO_ADD(x, y)</div></div>
<div class="ttc" id="amem__sdram_8c_html_a9ef7e7053d4000fe99a7eacc8d9346d7"><div class="ttname"><a href="mem__sdram_8c.html#a9ef7e7053d4000fe99a7eacc8d9346d7">sdram_free</a></div><div class="ttdeci">uint8_t sdram_free(void *ptr)</div><div class="ttdoc">释放一块内存</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00183">mem_sdram.c:183</a></div></div>
<div class="ttc" id="amem__sdram_8c_html_ae1630464a6d7686e9e41daf4b38e74a8"><div class="ttname"><a href="mem__sdram_8c.html#ae1630464a6d7686e9e41daf4b38e74a8">sdram_malloc</a></div><div class="ttdeci">void * sdram_malloc(size_t size)</div><div class="ttdoc">申请一块内存</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00130">mem_sdram.c:130</a></div></div>
<div class="ttc" id="amem__sdram_8c_html_afaf774943f1ebd4ab9b70edd87be3bce"><div class="ttname"><a href="mem__sdram_8c.html#afaf774943f1ebd4ab9b70edd87be3bce">MEM_ALIGN_UP</a></div><div class="ttdeci">#define MEM_ALIGN_UP(size)</div><div class="ttdoc">返回对齐 size 后的值(向上对齐)</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00050">mem_sdram.c:50</a></div></div>
<div class="ttc" id="amem__sdram_8c_html_afeab576605dd7cd387b47f9a54203abb"><div class="ttname"><a href="mem__sdram_8c.html#afeab576605dd7cd387b47f9a54203abb">MAGIC_SWM34S</a></div><div class="ttdeci">#define MAGIC_SWM34S</div><div class="ttdoc">内存块标识符</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00061">mem_sdram.c:61</a></div></div>
<div class="ttc" id="amem__sdram_8h_html"><div class="ttname"><a href="mem__sdram_8h.html">mem_sdram.h</a></div><div class="ttdoc">管理片内 SDRAM 存储空间</div></div>
<div class="ttc" id="astructmem__header__t_html"><div class="ttname"><a href="structmem__header__t.html">mem_header_t</a></div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00066">mem_sdram.c:67</a></div></div>
<div class="ttc" id="astructmem__header__t_html_a43dc3ebb377552917742f3765e0517d0"><div class="ttname"><a href="structmem__header__t.html#a43dc3ebb377552917742f3765e0517d0">mem_header_t::magic</a></div><div class="ttdeci">size_t magic</div><div class="ttdoc">内存块标识符</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00068">mem_sdram.c:68</a></div></div>
<div class="ttc" id="astructmem__header__t_html_a735984d41155bc1032e09bece8f8d66d"><div class="ttname"><a href="structmem__header__t.html#a735984d41155bc1032e09bece8f8d66d">mem_header_t::data</a></div><div class="ttdeci">void * data</div><div class="ttdoc">内存块首地址</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00070">mem_sdram.c:70</a></div></div>
<div class="ttc" id="astructmem__header__t_html_a854352f53b148adc24983a58a1866d66"><div class="ttname"><a href="structmem__header__t.html#a854352f53b148adc24983a58a1866d66">mem_header_t::size</a></div><div class="ttdeci">size_t size</div><div class="ttdoc">内存块已分配的大小 / Bytes(已包含sizeof(mem_header_t))</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00069">mem_sdram.c:69</a></div></div>
<div class="ttc" id="astructmm__t_html"><div class="ttname"><a href="structmm__t.html">mm_t</a></div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00073">mem_sdram.c:74</a></div></div>
<div class="ttc" id="astructmm__t_html_a685609860d73ccd0d45ada287ab9ab5f"><div class="ttname"><a href="structmm__t.html#a685609860d73ccd0d45ada287ab9ab5f">mm_t::size</a></div><div class="ttdeci">const size_t size</div><div class="ttdoc">内存池总大小 / Bytes</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00076">mem_sdram.c:76</a></div></div>
<div class="ttc" id="astructmm__t_html_a940ad597a7133d62ca5d36643d8038e9"><div class="ttname"><a href="structmm__t.html#a940ad597a7133d62ca5d36643d8038e9">mm_t::thread_mutex</a></div><div class="ttdeci">uint8_t thread_mutex</div><div class="ttdoc">线程互斥锁(0:空闲 1:占用)</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00083">mem_sdram.c:83</a></div></div>
<div class="ttc" id="astructmm__t_html_a9f8bf599d89043703a2ccce45dfc6343"><div class="ttname"><a href="structmm__t.html#a9f8bf599d89043703a2ccce45dfc6343">mm_t::ptr</a></div><div class="ttdeci">size_t ptr</div><div class="ttdoc">内存读写指针, 始终指向下一块空闲内存 (地址向上增长)</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00084">mem_sdram.c:84</a></div></div>
<div class="ttc" id="astructmm__t_html_af042d159841ddd8f248d6d49bbcbc38c"><div class="ttname"><a href="structmm__t.html#af042d159841ddd8f248d6d49bbcbc38c">mm_t::addr</a></div><div class="ttdeci">const void * addr</div><div class="ttdoc">内存池起始地址</div><div class="ttdef"><b>Definition:</b> <a href="mem__sdram_8c_source.html#l00075">mem_sdram.c:75</a></div></div>
<div class="ttc" id="aversion_8h_html"><div class="ttname"><a href="version_8h.html">version.h</a></div><div class="ttdoc">版本/目标控制</div></div>
<div class="ttc" id="aversion_8h_html_a13286deaebfd1c39a4e3638e8718c274"><div class="ttname"><a href="version_8h.html#a13286deaebfd1c39a4e3638e8718c274">LCD_VDOT</a></div><div class="ttdeci">#define LCD_VDOT</div><div class="ttdef"><b>Definition:</b> <a href="version_8h_source.html#l00189">version.h:189</a></div></div>
<div class="ttc" id="aversion_8h_html_a23a8c652045ed1831883b0c6785bea16"><div class="ttname"><a href="version_8h.html#a23a8c652045ed1831883b0c6785bea16">LCD_HDOT</a></div><div class="ttdeci">#define LCD_HDOT</div><div class="ttdef"><b>Definition:</b> <a href="version_8h_source.html#l00188">version.h:188</a></div></div>
<div class="ttc" id="aversion_8h_html_a52545d915cb8a3be458871130e58997a"><div class="ttname"><a href="version_8h.html#a52545d915cb8a3be458871130e58997a">SDRAMM_SIZE</a></div><div class="ttdeci">#define SDRAMM_SIZE</div><div class="ttdoc">SDRAMM_SIZE : 内置的 SDRAM 大小,提供客制化选项</div><div class="ttdef"><b>Definition:</b> <a href="version_8h_source.html#l00267">version.h:267</a></div></div>
<div class="ttc" id="aversion_8h_html_ae3f7a8bd03ba0b575f7ece837aab91aa"><div class="ttname"><a href="version_8h.html#ae3f7a8bd03ba0b575f7ece837aab91aa">LCD_FMT</a></div><div class="ttdeci">#define LCD_FMT</div><div class="ttdoc">enum : LCD 显示格式(LCD_FORMAT) 其值为一个像素点所占用的字节数, 可使用该值结合分辨率计算一帧显示缓存的大小</div><div class="ttdef"><b>Definition:</b> <a href="version_8h_source.html#l00246">version.h:246</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5
</small></address>
</body>
</html>
